package test19.outputstream_;

import java.io.*;

public class ObjectOutStream_ {
    public static void main(String[] args) throws IOException {
        //序列化后，保存的文件格式，不是存文本，而是按照他的格式来保存
        String filePath = "D:\\data.txt";
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(filePath));
        //序列化数据
        objectOutputStream.writeInt(100);
        objectOutputStream.writeBoolean(true);
        objectOutputStream.writeChar('a');
        objectOutputStream.writeDouble(9.5);
        objectOutputStream.writeUTF("教育");
        //保存一个dog对象
        objectOutputStream.writeObject(new Dog("旺财", 10,"韩国","白色"));
        objectOutputStream.close();
        System.out.printf("数据保存完毕(序列化形式)");
    }
}